package didi;

import java.util.Scanner;

/**
 * 求数组大最大累加和
 */
public class Main2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while (sc.hasNext()) {
            String[] str = sc.nextLine().split(" ");
            int[] arr = new int[str.length];
            for (int i = 0; i < str.length; i++){
                arr[i] = Integer.parseInt(str[i]);
            }

            System.out.println(help(arr));
        }
    }

    private static int help(int[] arr) {
        int max = Integer.MIN_VALUE;
        int tmp = 0;
        int left = 0, right = 0;
        for (int i = 0,n = arr.length; i < n; i++) {
            tmp += arr[i];
            if (tmp > max) {
                right = i;
                max = tmp;
            } else if (tmp < 0) {
                left = i + 1;
                tmp = 0;
            }
        }
        return max;
    }
}

